<template>
  <div>
    <van-nav-bar title="实名认证" left-text="返回" left-arrow @click-left="$router.go(-1)"/>
    <br/>
    <van-form ref="form" colon @submit="onSubmit">
      <van-cell-group inset>
        <van-field v-model="form.sequence" name="sequence" label="身份证号码" placeholder="请输入身份证号码"
                   :rules="[{ required: true }]"/>
        <van-field v-model="form.realname" name="realname" label="真实姓名" placeholder="请输入真实姓名"
                   :rules="[{ required: true }]"/>
        <br/>
        <van-cell :border="false">
          <van-button round block type="info" native-type="submit">提交</van-button>
        </van-cell>
      </van-cell-group>
    </van-form>
  </div>
</template>

<script>
import {Dialog} from 'vant'

export default {
  data() {
    return {
      form: {
        sequence: null,
        realname: null,
      }
    }
  },
  methods: {
    onSubmit(form) {
      this.$requests.post('/aliyun/identity', form).then(resp => {
        if (resp) {
          Dialog.alert({
            title: '提示',
            message: '恭喜你完成实名认证，我们将在3个工作日内为你免费开通30天全量数据使用权益。',
          }).then(() => {
            this.$router.replace('/mine/stock')
          })
        }
      })
    }
  }
}
</script>
